﻿@model DTcms.Model.user_groups
@{
    ViewBag.Title = "编辑会员组";
}
<form id="form1" class="layui-form" url="GroupSave?action=@ViewBag.action&id=@ViewBag.id">
    @Html.AntiForgeryToken()
    <!--导航栏-->
    <div class="pageheader">
        <div class="page-bar">
            <ul class="page-breadcrumb">
                <li><a href="../users/group_list" class="back"><i class="fa fa-mail-reply-all"></i> 返回列表页</a></li>
                <li><a href="javascript:;"><i class="iconfont icon-home1"></i> 首页</a> </li>
                <li><a href="javascript:;">会员组别</a> </li>
                <li><a href="javascript:;">编辑组别</a> </li>
            </ul>
        </div>
    </div>
    <!--/导航栏-->
    <!--内容-->
    <div class="layui-fluid">
        <div class="layui-tab layui-tab-card">
            <ul class="layui-tab-title" id="floatHead">
                <li class="layui-this">基本信息</li>
            </ul>
            <div class="layui-tab-content">
                <div class="layui-tab-item layui-show">
                    <div class="layui-form-item">
                        <label class="layui-form-label">组别名称</label>
                        <div class="layui-input-block">
                            @Html.TextBox("title", Model.title, new { @class = "input normal", datatype = "*1-100", minlength = "2", maxlength = "100" })
                            <span class="Validform_checktip">*</span>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">组别图标</label>
                        <div class="layui-input-block">
                            @Html.TextBox("img_url", Model.img_url, new { @class = "input normal upload-path" })
                            <div class="upload-box choose-pick"><a href="javascript:;" class="webuploader-pick" title="图片空间">选择图片</a></div>
                            <div class="upload-box upload-img"></div>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">是否隐藏</label>
                        <div class="layui-input-block">
                            @Html.CheckBox("is_lock", Model.is_lock == 1, new { title = "是" })
                            <span class="Validform_checktip">*隐藏后，用户将无法升级或显示该组别</span>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">注册默认会员组</label>
                        <div class="layui-input-block">
                            @Html.CheckBox("is_default", Model.is_default == 1, new { title = "是" })
                            <span class="Validform_checktip">*用户注册成功后自动默认为该会员组，如果存在多条，则以等级值最小的为准</span>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">参与自动升级</label>
                        <div class="layui-input-block">
                            @Html.CheckBox("is_upgrade", Model.is_upgrade == 1, new { title = "是" })
                            <span class="Validform_checktip">*如果是否，在满足升级条件下系统则不会自动升级为该会员组</span>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">等级值</label>
                        <div class="layui-input-block">
                            @Html.TextBox("grade", Model.grade, new { @class = "input small", datatype = "n" })
                            <span class="Validform_checktip">*升级顺序，取值范围1-100，等级值越大，会员等级越高。</span>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">升级所需经验</label>
                        <div class="layui-input-block">
                            @Html.TextBox("upgrade_exp", Model.upgrade_exp, new { @class = "input small", datatype = @"/^-?\d+$/" })
                            <span class="Validform_checktip">*自动升级所需要的经验值。</span>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">升级所需冲值金额</label>
                        <div class="layui-input-block">
                            @Html.TextBox("upgrade_price", Model.upgrade_price, new { @class = "input small", datatype = @"/^(([1-9]{1}\d*)|([0]{1}))(\.(\d){1,2})?$/" })
                            <span class="Validform_checktip">*自动升级所需要一次冲值的金额，0为不参与。</span>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">初始金额</label>
                        <div class="layui-input-block">
                            @Html.TextBox("amount", Model.amount, new { @class = "input small", datatype = @"/^-?(([1-9]{1}\d*)|([0]{1}))(\.(\d){1,2})?$/" })
                            <span class="Validform_checktip">*自动到该会员组赠送的金额，负数则扣减。</span>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">初始积分</label>
                        <div class="layui-input-block">
                            @Html.TextBox("point", Model.point, new { @class = "input small", datatype = @"/^-?\d+$/" })
                            <span class="Validform_checktip">*自动到该会员组赠送的积分，负数则扣减。</span>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">购物折扣</label>
                        <div class="layui-input-block">
                            @Html.TextBox("discount", Model.discount, new { @class = "input small", datatype = "n" })
                            <span class="Validform_checktip">*购物享受的折扣，取值范围1-100。</span>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!--/内容-->
    <!--工具栏-->
    <div class="page-footer">
        <div class="btn-wrap">
            <button class="layui-btn icon-btn" id="btnSubmit"><i class="layui-icon layui-icon-ok"></i>提交保存</button>
            <button class="layui-btn layui-btn-warm icon-btn" name="btnReturn" onclick="javascript:history.back(-1);"><i class="layui-icon layui-icon-return"></i>返回上一页</button>
        </div>
    </div>
    <!--/工具栏-->
</form>
@section Scripts{
    <script type="text/javascript" src="/scripts/libs/js/uploader.js"></script>
    <script type="text/javascript">
        layui.use(['validform', 'element', 'jqueryform', 'fileChoose'], function () {
            var fileChoose = layui.fileChoose;

            //初始化表单验证
            $("#form1").initValidform('#btnSubmit', 1);
            $('.choose-pick').click(function () {
                var obj = $(this);
                fileChoose.open({
                    fileUrl: '',
                    listUrl: '/admin_ajax/files',
                    num: 1,
                    dialog: {
                        offset: '60px'
                    },
                    onChoose: function (res) {
                        if (res[0].type != "file") {
                            layer.msg('我只让你选择图片格式的文件', { icon: 2, time: 2000 }, function () { });
                            return;
                        }
                        obj.siblings(".upload-path").val(res[0].url);
                        obj.siblings(".layer-photos").show().find("img").attr("src", res[0].url);
                    }
                });
            });
            //初始化上传控件
            $(".upload-img").InitUploader({ sendurl: "/upload_ajax/action", swf: "/scripts/libs/module/uploader/uploader.swf" });
        });
    </script>
}